#!/bin/bash
#############################################################
# Name:        Supportconfig Plugin for NOWS SBE MailScanner
# Description: Gathers gateway virus scanner and spam detector
#              troubleshooting information
# License:     GPLv2
# Author:      Randy Goddard (randage@gmail.com)
#              Jason Record (jrecord@novell.com)
# Modified:    2010 Oct 21
#############################################################

SVER=2.02
RCFILE="/usr/lib/supportconfig/resources/scplugin.rc"
LOG_LINES=500	#0 means include the entire file
LOG_DIR="/var/log"
CONF_DIR="/etc"

[ -s $RCFILE ] && . $RCFILE || { echo "ERROR: Initializing resource file: $RCFILE"; exit 1; }

section_header "Supportconfig Plugin for NOWS SBE MailScanner, v${SVER}"

plugin_command "rpm -qa | egrep -i 'mailscanner' | sort"
RPMLIST=$(rpm -qa | egrep -i 'mailscanner' | sort)
if [ -z "$RPMLIST" ]; then
  echo "ERROR: Mail Scanner package(s) not installed"
  echo
  exit 111
fi

for THISRPM in $RPMLIST
do
   validate_rpm $THISRPM
done

for i in mailscanner
do
	if [ -s /etc/init.d/$i ]; then
		plugin_command "chkconfig -l $i"
		plugin_command "/etc/init.d/$i status"
		
	fi
done

plugin_command "ps axwwo user,pid,ppid,%cpu,%mem,vsz,rss,stat,time,cmd | egrep 'gwia|mailscanner|postfix' | egrep -v 'nowsbe_|grep'"
plugin_command "netstat -nlp | egrep ':25 |:26 '"
plugin_command "/usr/sbin/MailScanner -v"
pconf_files "$CONF_DIR/MailScanner/MailScanner.conf $CONF_DIR/sysconfig/postfix $CONF_DIR/postfix/main.cf /opt/novell/groupwise/agents/share/gwia.cfg"
plog_files $LOG_LINES "$LOG_DIR/mail $LOG_DIR/messages"

